import 'hammerjs';
/*Angular module*/
import { NgModule } from '@angular/core';
import { BrowserModule, Title, Meta, DomSanitizer } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FlexLayoutModule } from "@angular/flex-layout";
import { MdIconRegistry } from "@angular/material";
// import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http";

/*config*/
import { AppConfig } from "./config/index";
/*app module*/
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { NavigationModule } from "./module/navigation/navigation.module";
import { SecurityModule } from "./module/security/security.module";
/*shared module*/
import { SharedModule } from "./shared/shared.module";
/*service module*/
import { CanDeactivateGuard } from "./service/guard/can-deactivate.guard";
import { AuthGuard } from "./service/guard/auth.guard";

import { SetofDictService } from "./service/setof-dict.service";
import { TagDictService } from "./service/tag-dict.service";
import { MenuParamDictService } from "./service/menu-param-dict.service";
import { ApplicationService } from "./service/application.service";
import { NzMessageService } from 'ng-zorro-antd';
import { provideInterceptorService } from './service/interceptor/interceptor-provider';
import { RequestInterceptor } from './service/interceptor/request.interceptor';
import { InterceptorService } from './service/interceptor/interceptor-service';
import { XHRBackend, RequestOptions } from '@angular/http';

export function interceptorFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions, requestInterceptor: RequestInterceptor) {
  // Add it here
  let service = new InterceptorService(xhrBackend, requestOptions);
  service.addInterceptor(requestInterceptor); // Add it here
  return service;
}


@NgModule({
  /*declarations模块声明*/
  /*这里添加属于该模块的组件，指令�,
    CapacityViewComponent�管道*/
  declarations: [
    AppComponent,
  ],
  imports: [
    /*Angular module*/
    BrowserModule,
    BrowserAnimationsModule,
    /*zknwapp module*/
    AppRoutingModule,
    SecurityModule,
    NavigationModule
  ],
  providers: [
    RequestInterceptor,
    {
      provide: InterceptorService,
      useFactory: interceptorFactory,
      deps: [XHRBackend, RequestOptions, RequestInterceptor] // Add it here, in the same order as the signature of interceptorFactory
    },
    AuthGuard,
    CanDeactivateGuard,
    ApplicationService,
    AppConfig,
    SetofDictService,
    TagDictService,
    MenuParamDictService,
    NzMessageService,
  ],
  bootstrap: [AppComponent]
})
export class AppModule {

  /**
   * Creates an instance of AppModule.
   * @param {MdIconRegistry} mdIconRegistry
   * @param {DomSanitizer} domSanitizer
   * @param {ApplicationService} applicationService
   * @memberof AppModule
   */
  public constructor(
    private mdIconRegistry: MdIconRegistry,
    private domSanitizer: DomSanitizer,
    private applicationService: ApplicationService,
    private appConfig: AppConfig,
  ) {
    this.registryResources();
  }
  /**
   * 注册资源
   *
   * @memberof AppModule
   */
  public registryResources() {
    //SVG图标资源注册
    this.mdIconRegistry.addSvgIconInNamespace("assets", "logo", this.domSanitizer.bypassSecurityTrustResourceUrl("./assets/images/logo.svg"));
    this.mdIconRegistry.addSvgIconInNamespace("assets", "circle1", this.domSanitizer.bypassSecurityTrustResourceUrl("./assets/images/circle1.svg"));
    this.mdIconRegistry.addSvgIconInNamespace("assets", "lamp", this.domSanitizer.bypassSecurityTrustResourceUrl("./assets/images/lamp.svg"));
    this.mdIconRegistry.addSvgIconInNamespace("assets", "turbine", this.domSanitizer.bypassSecurityTrustResourceUrl("./assets/images/turbine.svg"));
  }

}



// WEBPACK FOOTER //
// ./src/app/app.module.ts